//
//  BalloonSprite.m
//  StarBugs
//
//  Created by ?? ? on 1/2/12.
//  Copyright 2012 antisword@playorca.com. All rights reserved.
//

#include "Object/BubbleSprite.h"
#include "Util/ImageManager.h"

BubbleSprite::~BubbleSprite()
{
//    if(frameArray)
//    {
//        frameArray->removeAllObjects();
//        frameArray->release();
//        frameArray = NULL;
//    }
//    
////    if(mainSprite)
////    {
////        mainSprite->removeAllChildrenWithCleanup(true);
////        mainSprite->release();
////        mainSprite = NULL;
////    }
}

BubbleSprite::BubbleSprite()
{
    mainSprite = ImageManager::getSpriteWithXml2(kImagesheet_GameSource, "ob_bubble");
    mainSprite->setScale(0.8f);
    addChild(mainSprite);
    objectType = objectType_balloon;
    enableFlg = true;
}

void BubbleSprite::setBody(b2World* _world)
{
    mainSprite->setPosition(position);
}

void BubbleSprite::startBoom()
{
    boomCnt = 0;
    schedule(schedule_selector(BubbleSprite::boomTick));
    enableFlg = false;
}

void BubbleSprite::boomTick(float dt)
{
    boomCnt ++;
    if(boomCnt == 5)
    {
        unschedule(schedule_selector(BubbleSprite::boomTick));
        removeFromParentAndCleanup(true);
    }
    
}